package softtech.apps.callblocker.adapter;

import softtech.apps.callblocker.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class AdapterSettingDashboard extends BaseAdapter {

	Context mContext;

	public static final int CASE_PASSWORD = 0;
	public static final int CASE_CALL_SETTING = 1;
	public static final int CASE_SMS_SETTING = 2;
	public static final int CASE_HISTORY_TIME = 3;
	public static final int CASE_FAKE_ICON = 4;
	public static final int CASE_FAKE_PASSWORD = 5;
	
	public AdapterSettingDashboard(Context context) {
		mContext = context;
	}

	@Override
	public int getCount() {
		return 6;
	}

	@Override
	public Object getItem(int position) {

		return null;
	}

	@Override
	public long getItemId(int position) {

		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder viewHolder = null;
		if (convertView == null) {
			LayoutInflater inflater = LayoutInflater.from(parent.getContext());
			convertView = inflater.inflate(R.layout.item_setting_dashboard,
					parent, false);

			viewHolder = new ViewHolder();
			viewHolder.tvNameManager = (TextView) convertView
					.findViewById(R.id.tvNameManager);
			viewHolder.tvDecription = (TextView) convertView
					.findViewById(R.id.tvDecription);
			viewHolder.imgIconSetting = (ImageView) convertView
					.findViewById(R.id.imgIconSetting);

			convertView.setTag(viewHolder);
			convertView.setTag(R.id.tvNameManager, viewHolder.tvNameManager);
			convertView.setTag(R.id.tvDecription, viewHolder.tvDecription);
			convertView.setTag(R.id.imgIconSetting, viewHolder.imgIconSetting);
		} else {
			viewHolder = (ViewHolder) convertView.getTag();
		}

		insertContentView(viewHolder, position);

		return convertView;

	}

	static class ViewHolder {
		protected TextView tvNameManager, tvDecription;
		protected ImageView imgIconSetting;
	}

	/**
	 * content of adapter
	 * 
	 * @param viewHolder
	 * @param position
	 */
	void insertContentView(ViewHolder viewHolder, int position) {
		switch (position) {
		case CASE_PASSWORD: // setting password for app
			viewHolder.tvNameManager.setText(mContext.getResources().getString(R.string.password_setting));
			viewHolder.tvDecription.setText(mContext.getResources().getString(R.string.password_setting_description));
			viewHolder.imgIconSetting.setImageDrawable(mContext.getResources().getDrawable(R.drawable.ic_enable));
			break;
		case CASE_SMS_SETTING: // setting block sms
			viewHolder.tvNameManager.setText(mContext.getResources().getString(R.string.sms_block_setting));
			viewHolder.tvDecription.setText(mContext.getResources().getString(R.string.sms_block_setting_description));
			viewHolder.imgIconSetting.setImageDrawable(mContext.getResources().getDrawable(R.drawable.ic_enable));
			break;
		case CASE_CALL_SETTING: // setting block call
			viewHolder.tvNameManager.setText(mContext.getResources().getString(R.string.call_block_setting));
			viewHolder.tvDecription.setText(mContext.getResources().getString(R.string.call_block_setting_description));
			viewHolder.imgIconSetting.setImageDrawable(mContext.getResources().getDrawable(R.drawable.ic_enable));
			break;
			
		case CASE_HISTORY_TIME: // setting time limited of history save
			viewHolder.tvNameManager.setText(mContext.getResources().getString(R.string.history_time_setting));
			viewHolder.tvDecription.setText(mContext.getResources().getString(R.string.history_time_setting_description));
			viewHolder.imgIconSetting.setImageDrawable(mContext.getResources().getDrawable(R.drawable.ic_enable));
			break;
		case CASE_FAKE_ICON: // fake icon
			viewHolder.tvNameManager.setText(mContext.getResources().getString(R.string.fake_icon_setting));
			viewHolder.tvDecription.setText(mContext.getResources().getString(R.string.fake_icon_setting_description));
			viewHolder.imgIconSetting.setImageDrawable(mContext.getResources().getDrawable(R.drawable.ic_enable));
			break;
		case CASE_FAKE_PASSWORD: // fake password
			viewHolder.tvNameManager.setText(mContext.getResources().getString(R.string.fake_password_setting));
			viewHolder.tvDecription.setText(mContext.getResources().getString(R.string.fake_password_setting_description));
			viewHolder.imgIconSetting.setImageDrawable(mContext.getResources().getDrawable(R.drawable.ic_enable));
			break;
		default:
			break;
		}
	}

}
